//
//  FreezeFormView.h
//  etionUI
//
//  Created by wangjian on 12/24/13.
//  Copyright (c) 2013 GuangZhouXuanWu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "FormView.h"

typedef enum {EGradientDirectionLeft, EGradientDirectionDown, EGradientDirectionUp} EGradientDirection;

@interface CGradientView : UIView

@property (nonatomic, readonly) CGGradientRef gradient;
@property (nonatomic, assign) EGradientDirection gradientDir;

@end


typedef enum
{
    EFreezeFormStyleNone,
    EFreezeFormStyleClassic
} EFreezeFormStyle;

@class CFreezeFormView;
@protocol CFreezeFormViewDelegate <UIScrollViewDelegate>

- (CFormCellView *)freezeFormView:(CFreezeFormView *)view cellAtIndex:(CFormCellIndex *)index;
- (void)freezeFormView:(CFreezeFormView *)view didClickCellAtIndex:(CFormCellIndex *)index;

@optional
- (CGFloat)freezeFormView:(CFreezeFormView *)view heightForRow:(NSUInteger)row;
- (CGFloat)freezeFormView:(CFreezeFormView *)view widthForCol:(NSUInteger)col;

- (void)freezeFormView:(CFreezeFormView *)view contentOffsetChange:(CGPoint)contentOffset;
- (void)freezeFormView:(CFreezeFormView *)view contentSizeChange:(CGSize)contentSize;

@end

@interface CFreezeFormView : UIView <CFormViewDelegate>

@property (nonatomic, assign) id<CFreezeFormViewDelegate> delegate;
@property (nonatomic, readonly) UIView *contentView;
@property (nonatomic, retain) CFormCellIndex *curSelectedIndex;

@property (nonatomic, retain) UIColor *renderColor;

@property (nonatomic, assign) NSUInteger rowNum;
@property (nonatomic, assign) NSUInteger colNum;
@property (nonatomic, assign) NSUInteger freezeTopRowNum;
@property (nonatomic, assign) NSUInteger freezeColNum;
@property (nonatomic, assign) NSUInteger freezeBottomRowNum;

@property (nonatomic, readonly) CGRect contentFrame;

- (void)reload;
- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndex:(CFormCellIndex *)index;

- (CFormCellView *)cellAtIndex:(CFormCellIndex *)index;
- (CFormCellIndex *)indexForCell:(CFormCellView *)cell;
- (CGRect)frameOfCellAtIndex:(CFormCellIndex *)index;

- (void)scrollToIndex:(CFormCellIndex *)index animated:(BOOL)animated;

- (CGFloat)heightForRow:(NSUInteger)row;
- (CGFloat)widthForCol:(NSUInteger)col;
- (void)setHeight:(CGFloat)height forRow:(NSUInteger)row animated:(BOOL)animated;
- (void)setWidth:(CGFloat)width forCol:(NSUInteger)col animated:(BOOL)animated;

//- (void)contentSizeChange:(CGSize)size;
//- (void)formContentOffsetChange:(CGPoint)offset;
- (CGRect)notFreezeContentFrame;
- (CGPoint)formContentOffset;
- (void)scrollToFormContentOffset:(CGPoint)offset;
- (CGSize)contentDisplaySize;   //返回实际显示的区域大小

//UI style

@property (nonatomic, assign) EFreezeFormStyle style;
@property (nonatomic, assign) BOOL hasBorder;
@property (nonatomic, assign) CGFloat borderSize;
@property (nonatomic, retain) UIColor *borderColor;
@property (nonatomic, assign) CGFloat borderCornerRadius;

@end
